//
//  RecordEndView.m
//  record_plugin
//
//  Created by zqj on 2024/9/9.
//录制完成展示页面

#import "RecordEndView.h"

@interface RecordEndView()

@property (weak, nonatomic) IBOutlet UILabel *descLab;
@property (weak, nonatomic) IBOutlet UIButton *firstBtn;
@property (weak, nonatomic) IBOutlet UIButton *secondBtn;




@end

@implementation RecordEndView

+ (RecordEndView *)instance{
    RecordEndView *view = [[NSBundle bundleForClass:[self class]] loadNibNamed:@"RecordEndView" owner:self options:nil].firstObject;
    return view;
}


- (IBAction)reRecordClicked:(UIButton *)sender {
    if (self.rerecordBlock) {
        self.rerecordBlock(self.utilityType);
    }
}

- (IBAction)completeClicked:(UIButton *)sender {
    if (self.continueBlock) {
        self.continueBlock(self.utilityType);
    }
}


- (void)setUtilityType:(UtilityType)utilityType{
    _utilityType = utilityType;
    if (utilityType == RecordEnd) {
        self.descLab.text = @"感谢您的配合，视频录制完成。";
        [self.firstBtn setTitle:@"重录" forState:UIControlStateNormal];
        [self.secondBtn setTitle:@"继续" forState:UIControlStateNormal];

    }else if (utilityType == FaceComparison){
        self.descLab.text = @"人脸与身份证照片对比，检测分数过低，请确保是本人录制。";
        [self.firstBtn setTitle:@"重录" forState:UIControlStateNormal];
        [self.secondBtn setTitle:@"确认是本人" forState:UIControlStateNormal];


    }else if(utilityType == AnswerComparison){
        NSString *titleStr = @"再次回答点击重播，已回答点击继续";
        NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc] initWithString:titleStr];
        [attributedText addAttribute:NSForegroundColorAttributeName value:[UIColor blueColor] range:NSMakeRange(0, titleStr.length)];
        NSString *msgStr = @"\n\n识别回答:不清楚";
        NSMutableAttributedString *attributed = [[NSMutableAttributedString alloc] initWithString:msgStr];
        [attributed addAttribute:NSForegroundColorAttributeName value:[UIColor whiteColor] range:NSMakeRange(0, msgStr.length)];
        [attributedText appendAttributedString:attributed];
        self.descLab.attributedText = attributedText;
        [self.firstBtn setTitle:@"重播" forState:UIControlStateNormal];
        [self.secondBtn setTitle:@"继续" forState:UIControlStateNormal];
    }
}

@end
